<template>
  <div class="tag-detail-enums">
    <!-- <tag-enums :tagId="tagId" :small="false"></tag-enums> -->
    <tag-content-header search refresh setting @toolFun="toolFun" :settingData="columns"> </tag-content-header>
    <tag-table
      ref="table"
      @refresh="getInfo"
      :data="dataList"
      :loading="loading"
      :columns="columns"
      :params="params"
      :total="totalSize"
    >
    </tag-table>
  </div>
</template>

<script>
export default {
  props: {
    tagId: {
      type: String,
      require: true,
      default: ''
    }
  },
  data() {
    return {
      dataList: [],
      loading: false,
      columns: [
        {
          show: true,
          label: '枚举值',
          prop: 'cdVal',
          search: true,
          searchKey: ''
        },
        {
          show: true,
          label: '枚举值描述',
          prop: 'cdDesc',
          search: true,
          searchKey: '',
          align: 'center'
        }
      ],
      params: {
        ascs: [],
        descs: [],
        currentPageNum: 1,
        pageSize: 10,
        queryParams: {},
        descPriority: false
      },
      totalSize: 0
    }
  },
  methods: {
    toolFun(operation) {
      switch (operation) {
        case 'search':
          // 搜索动作
          this.$refs['table'].searchToggle()
          break
        case 'refresh':
          // 刷新动作
          this.getInfo()
          break
      }
    },
    getInfo() {
      this.params.queryParams.tagId = this.tagId
      this.params.queryParams.onLineFlag = 1
      this.loading = true
      this.$ajax({
        url: this.$ajax.setUrl('ast/astTagEnumVal/pageList'),
        method: 'get',
        params: this.$ajax.setParams(this.params)
      }).then(({ data }) => {
        if (data && data.code === '0') {
          if (data.data.currentPageNum === this.params.currentPageNum) {
            this.dataList = data.data.records
            this.totalSize = data.data.totalSize
          }
        } else {
          this.$message.error('获取枚举值列表失败！')
        }
        this.loading = false
      })
    }
  }
}
</script>

<style lang="scss">
.tag-detail-enums {
  .tag-content-header {
    margin-top: 10px;
  }
}
</style>
